package com.xxx.blog.service.impl;

import com.github.pagehelper.PageHelper;
import com.xxx.blog.domain.Article;
import com.xxx.blog.mapper.ArticleMapper;
import com.xxx.blog.query.ArticleQuery;
import com.xxx.blog.service.IArticleService;
import com.xxx.blog.vo.GdVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service//
public class ArticleServiceImpl implements IArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public List<Article> findAll() {
        return articleMapper.findAll();
    }

    @Override
    public Article findOne(Long id) {
        return articleMapper.findOne(id);
    }

    @Override
    public List<Article> queryPage(ArticleQuery articleQuery) {
        PageHelper.startPage(articleQuery.getCurrentPage(), articleQuery.getPageSize());

        return articleMapper.queryPage(articleQuery);
    }

    @Override
    public void addArticle(Article article) {
        articleMapper.addArticle(article);
    }

    @Override
    public void updateArticle(Article article) {
        articleMapper.updateArticle(article);
    }

    //alt shif p
    @Override
    public void deleteArticle(Long id) {
        articleMapper.deleteArticle(id);
    }

    @Override
    public void batchArticles(Long[] ids) {
        articleMapper.batchArticles(ids);
    }

    @Override
    public List<GdVo> getGd() {
        return articleMapper.getGd();
    }

    @Override
    public List<Article> getRa(Long id) {
        Article articles = articleMapper.findOne(id);
        return articleMapper.getRa(articles);
    }
}
